using System;
using UnityEngine;

public class FlyingDrone : MonoBehaviour
{
	public Animator droneAnimator;

	public GameObject rewardCase;

	private bool needBringTheCase;

	public static Action OnDroneArrived;

	public static Action OnDroneArrives;

	public bool HasRewardCase
	{
		get
		{
			return rewardCase.activeSelf;
		}
	}

	private void OnEnable()
	{
		OnDroneArrives = (Action)Delegate.Combine(OnDroneArrives, new Action(TurnOnTheCase));
	}

	private void OnDisable()
	{
		OnDroneArrives = (Action)Delegate.Remove(OnDroneArrives, new Action(TurnOnTheCase));
	}

	public void TurnOnTheCase()
	{
		rewardCase.SetActive(needBringTheCase);
	}

	public void SetNeedCase(bool needCase)
	{
		needBringTheCase = needCase;
	}

	public void ArriveWithoutCase()
	{
		droneAnimator.SetTrigger("Down");
		needBringTheCase = false;
	}

	public void ArriveWithCase()
	{
		droneAnimator.SetTrigger("Down");
		needBringTheCase = true;
	}

	public void FlyAway()
	{
		droneAnimator.SetTrigger("Up");
	}

	public void FlyAwayAndReturn(bool withCase)
	{
		droneAnimator.SetTrigger("Up");
		if (withCase)
		{
			ArriveWithCase();
		}
		else
		{
			ArriveWithoutCase();
		}
	}

	public void DroneArrivesEvent()
	{
		if (OnDroneArrives != null)
		{
			OnDroneArrives();
		}
	}

	public void DroneArrivedEvent()
	{
		if (OnDroneArrived != null)
		{
			OnDroneArrived();
		}
	}
}
